package actions;

import game.constants.ReferenceAction;
import game.constants.ReferenceSpecialFeature;
import interfaces.ActionInterface;
import interfaces.impl.Action;

import java.util.ArrayList;

import objects.SpetialFeature;
import universe.Universe;
import constants.Constants;

public class ActionEquipe extends Action{

	@Override
	public boolean processActionChild(Universe universe) {
		
		SpetialFeature equiped = target.getFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_OBJECT_EQUIPED);
		if(equiped==null){
			return false;
		}
		equiped.setValue(Constants.TRUE);
		
		//busco la lista de spetial features que voy a modificar en el source del target
		ArrayList<SpetialFeature> listModify = new ArrayList<SpetialFeature>();
		for(SpetialFeature feature : target.getListFeatures()){
			if(feature.getAditionalInfo().equals(Constants.FEATURE_TO_MODIFY)){
				listModify.add(feature);
			}
		}
		
		for(SpetialFeature featureToModify : listModify ){
			for(SpetialFeature feature : source.getListFeatures() ){
				if(featureToModify.getId()==feature.getId()){
					feature.setValue(feature.getValue()+featureToModify.getValue());
					break;
				}
			}
		}
		return false;
	}

	@Override
	public void initializeName() {
		name="�ction Equipe";
		
	}

	@Override
	public void initializeId() {
		this.id=ReferenceAction.ACTION_EQUIPE;
		
	}

	@Override
	public void modifyChild(ActionInterface action) {

		
	}
	
	@Override
	public ActionEquipe cloneAction(){
		ActionEquipe action = new ActionEquipe();
		action.modifyAction(this);
		return action;
		
	}
	

}
